<template>
	<page-meta><navigation-bar title="积分充值" front-color="#000000" background-color="#ffffff" /></page-meta>
	<view>
		<view class="top" style="height: 220rpx;background: rgb(20,139,255);text-align: center;color: #fff;">
			<text style="padding-top: 50rpx;display: block;padding-bottom: 20rpx;">积分余额</text>
			<text style="font-size: 18px;">{{obj.fpoint}}</text>
		</view>
		<view style="margin-top: 20px;">
			<view class="" style="height: 80rpx;line-height: 80rpx;padding: 0 30rpx;margin-top: 20rpx;" @tap="nowid=0">
				<image src="/static/img/zhifubao.svg" mode="" style="width: 60rpx;height: 60rpx;float: left;margin-top: 13rpx;margin-right: 18rpx;"></image>
				<text>支付宝支付</text>
				<text style="width: 30rpx;height: 30rpx;display: block;border: 2px solid #ccc;float: right;border-radius: 50%;margin-top: 20rpx;" :class="{active:nowid==0}">
					
				</text>
			</view>
			<view class="" style="height: 80rpx;line-height: 80rpx;padding: 0 30rpx;margin-top: 20rpx;" @tap="nowid=1">
				<image src="/static/img/weixin.svg" mode="" style="width: 80rpx;height: 80rpx;float: left;margin-top: 3rpx;"></image>
				<text>微信支付</text>
				<text style="width: 30rpx;height: 30rpx;display: block;border: 2px solid #ccc;float: right;border-radius: 50%;margin-top: 20rpx;" :class="{active:nowid==1}">
					
				</text>
			</view>
		</view>
		<button @tap="sub" type="default" style="color: #fff;background:rgb(20,139,255) ;line-height: 45px;width: 100%;position: fixed;z-index: 10;bottom: 0;left: 0px;border-radius: 0;">充值</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nowid:0,
				obj:{}
			}
		},
		onNavigationBarButtonTap(e){
			this.$go('/pages/center/jifenmingxi');
		},
		methods: {
			getdata(){
				var _this = this;
				uni.request({
					method: 'post',
					url: _this.$store.state.url + '/api/shequuser/mycenter/getuserinfo?ftoken=' + _this.$store.state.user.token,
					// contentType: "application/json;",
					// data: JSON.stringify(_this.shisetdata),
					success: function(data) {
						// console.log(data)
						data = data.data;
						if (data.code == 200) {
							_this.obj = data.data;
						} else {
							
						}
					}
				})
			},
			sub(){
				var str = '';
				if(this.nowid == 0){
					str = 'zfb'
				}else{
					str = 'wx'
				};
				this.geturl(str);
			},
			geturl(str){
				var _this = this;
				uni.request({
					method: 'post',
					url: _this.$store.state.url + '/api/shequuser/mycenter/onlinpayhtml?ftoken='+_this.$store.state.user.token+'&fpaytype='+str,
					success: function(data) {
						data = data.data;
						if (data.code == 200) {
							_this.$go('/pages/center/zhifu?url='+ data.data,true)
							// console.log('/pages/center/zhifu?url='+ data.data)
						} else {
						}
					},
					fail: res => {
						console.log(res);
					}
				});
			}
		},
		onShow(){
			var _this = this;
			uni.getNetworkType({
				success: function(res) {
					if (res.networkType == 'none') {
						uni.showToast({
							title: '当前无网络连接，请检查！',
							icon: 'none',
							duration: 5000
			
							// position:'top'
						});
					}
				}
			});
			uni.onNetworkStatusChange(function(res) {
				if (!res.isConnected) {
					uni.showToast({
						title: '当前无网络连接，请检查！',
						icon: 'none',
						duration: 3000
						// position:'top'
					});
				} else {
					uni.showToast({
						title: '网络已连接！',
						icon: 'none',
						duration: 3000
						// position:'top'
					});
					_this.getdata();
				}
			});
			_this.getdata();
			this.height = uni.getSystemInfoSync().windowHeight;
		}
	}
</script>

<style scoped>
	.active{
		color: #fff;
		background: rgb(20,139,255);
		border: 2px solid rgb(20,139,255) !important;
		line-height: 30rpx;
		text-align: center;
		font-size: 12px;
	}
	.active::after{
		content: '✓';
	}
</style>
